package com.btex.app.treaty.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.btex.app.R;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author zy zhangyi <zhangyi, 1104745049@QQ.com
 * @version v1.0
 * @project study1
 * @Description
 * @encoding UTF-8
 * @date 2018/10/15
 * @time 下午6:05
 * @修改记录 <pre>
 * 版本       修改人         修改时间         修改内容描述
 * --------------------------------------------------
 * <p>
 * --------------------------------------------------
 * </pre>
 */

public class MoShiDialog extends Dialog {

    @NonNull
    private Context mContext;
    private ArrayList<String> mStrings;
    private String mLeverage;
    private String mGanggan;
    private String mMIs_cross;
    private String mAllow_cross;
    private String mPriceNumber;
    private String mPrice_float_num;
    @BindView(R.id.treaty_tv_set)
    TextView mTreatyTvSet;
    @BindView(R.id.treaty_tv_guide)
    TextView mTreatyTvGuide;
    @BindView(R.id.treaty_tv_diss)
    TextView mTreatyTvDiss;

    public MoShiDialog(@NonNull Context context, ArrayList<String> strings, String leverage, String ganggan, String mIs_cross, String allow_cross, String priceNumber,String Price_float_num) {
        super(context, R.style.coupon_style);
        mContext = context;
        mStrings = strings;
        mLeverage = leverage;
        mGanggan = ganggan;
        mMIs_cross = mIs_cross;
        mAllow_cross = allow_cross;
        mPriceNumber = priceNumber;
        mPrice_float_num = Price_float_num;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mo_shi_dialog);
        ButterKnife.bind(this);

        //获取屏幕宽高
        DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
        //屏幕宽
        int widthPixels = displayMetrics.widthPixels;
        //屏幕高
        int heightPixels = displayMetrics.heightPixels;
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        //设置给attributes
        attributes.width = (int) (widthPixels * 1);
        attributes.height = (int) (heightPixels * 0.35);
        //让Dialog位置居中
        attributes.gravity = Gravity.BOTTOM;
        getWindow().setAttributes(attributes);
        //点击空白处不dismiss
        setCanceledOnTouchOutside(true);


    }

    @OnClick({R.id.treaty_tv_set, R.id.treaty_tv_guide, R.id.treaty_tv_diss})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.treaty_tv_set:
                new CangweiMoshiDialog(mContext, mStrings, mLeverage, mGanggan, mMIs_cross, mAllow_cross, mPriceNumber,mPrice_float_num).show();
                dismiss();
                break;
            case R.id.treaty_tv_guide:
                if ("1".equals(mAllow_cross)) {

                    Log.i("wejfweifowjeijfw", "1111111111111111");
                    new LeverDialog(mContext, mStrings, mLeverage, mGanggan, mMIs_cross, mAllow_cross, mPriceNumber,mPrice_float_num).show();
                } else {

                    new NoLeverDialog(mContext, mStrings, mLeverage, mGanggan, mMIs_cross, mAllow_cross, mPriceNumber,mPrice_float_num).show();
                }
                dismiss();
                break;
            case R.id.treaty_tv_diss:
                this.dismiss();
                break;
        }
    }
}
